package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.FixedAssetsEntity;
import com.jinmdz.fmis.mapper.mapper.provider.FixedAssetsProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 固定资产表Mapper
 *
 * @author generator
 * @date 2020-03-12 17:08
 */
public interface FixedAssetsMapper {

    /**
     * 增加FixedAssets
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @InsertProvider(type = FixedAssetsProvider.class, method = "insertFixedAssets")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertFixedAssets(@Param("entity") FixedAssetsEntity entity);

    /**
     * 删除FixedAssets
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Update(" update fixed_assets set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForFixedAssets(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改FixedAssets
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @UpdateProvider(type = FixedAssetsProvider.class, method = "updateFixedAssets")
    void updateFixedAssets(@Param("entity") FixedAssetsEntity entity);

    /**
     * 查询FixedAssets实体
     *
     * @param id 主键
     * @return FixedAssetsEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Select(" select id,deleted,assets_no,assets_name,specification_no,assets_unit,manufacturer,use_department,assets_source,depreciation_degree,depreciation_year,original_value,enable_date,use_state,scrap_date,remark,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from fixed_assets where id = #{id} and deleted = 0 limit 1 ")
    FixedAssetsEntity getFixedAssetsById(@Param("id") Integer id);

    /**
     * 查询FixedAssets列表
     *
     * @param entity 数据实体
     * @return FixedAssetsEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @SelectProvider(type = FixedAssetsProvider.class, method = "listFixedAssets")
    ArrayList<FixedAssetsEntity> listFixedAssets(@Param("entity") FixedAssetsEntity entity);
}